package com.example.designModel.strategy;

import com.sun.org.apache.bcel.internal.generic.RET;
import org.springframework.core.annotation.Order;

import javax.annotation.Priority;

/**
 * 返利收费
 */
@Order
public class CashReturn extends CashSuper {
    //返利条件
    private double moneyCondition = 0.0d;
    //返利金额
    private double moneyReturn = 0.0d;
    public int test(CashReturn a){
        return 1;
    }
    public CashReturn(String moneyCondition, String moneyReturn) {
        this.moneyCondition = Double.parseDouble(moneyCondition);
        this.moneyReturn = Double.parseDouble(moneyReturn);
    }

    @Override
    public double acceptCash(double money) {
        double result = money;
        if (money >= moneyCondition) {
            result = money - Math.floor(money / moneyCondition) * moneyReturn;
        }
        return result;
    }

    public void setMoneyCondition(double moneyCondition) {
        this.moneyCondition = moneyCondition;
    }

    public void setMoneyReturn(double moneyReturn) {
        this.moneyReturn = moneyReturn;
    }

    public double getMoneyCondition() {
        return moneyCondition;
    }

    public double getMoneyReturn() {
        return moneyReturn;
    }
}
